//
//  HLEBaseRequest.h
//  HLENetwork_Example
//
//  Created by hle1879 on 2020/9/29.
//  Copyright © 2020 13434436448@163.com. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "HLENetWorkConfig.h"

@class HLEBaseResponse;
@class HLESessionManager;

///请求结果的回调
typedef void(^HLENetWorkResult)(HLEBaseResponse * _Nonnull response);

///上传下载的进度
typedef void(^HLENetWorkProgress)(NSProgress * _Nonnull progress,double progressRate);

///下载取消返回ResumeData
typedef void(^HLENetWorkDownloadCancelByResumeData)(NSData * _Nullable progress);

NS_ASSUME_NONNULL_BEGIN

@interface HLEBaseRequest : NSObject

///请求的地址
@property (nonatomic,copy) NSString *url;

///请求头
@property (nonatomic,copy) NSDictionary *requestHeader;

///请求的参数
@property (nonatomic,copy) NSDictionary *params;

///缓存策略 默认没有缓存
@property (nonatomic,assign) HLENetWorkCachePolicy cachePolicy;

///缓存的时间 默认7天
@property (nonatomic,assign) NSTimeInterval cacheValidTime;

///请求的方式 默认get
@property (nonatomic,assign) HLENetWorkRequestMethod method;

///请求完成的回调
@property (nonatomic,copy) HLENetWorkResult responseCompletion;

///获取缓存的回调
@property (nonatomic,copy) HLENetWorkResult cacheCompletion;

///请求对应的会话管理 默认default
@property (nonatomic,strong) HLESessionManager *session;

///是否开启打印日志，默认NO
@property (nonatomic,assign) BOOL enableLog;

///获取请求的任务
- (NSURLSessionDataTask*)getTask;

///发送请求
- (void)sendRequest;

///取消请求
- (void)cancelRequest;

///处理公共参数
- (NSDictionary *)disposePublicParameters;

///处理请求头
- (void)disposeRequestMutableHeaderField:(NSMutableURLRequest *)request;

///添加请求标识
- (void)addDelegateForDataTask;

///删除请求标识
- (void)removeDelegateForDataTask;
@end

NS_ASSUME_NONNULL_END
